//
//  PhotoTableViewCell.m
//  KIASupervisory
//
//  Created by tan_xin on 14-9-22.
//  Copyright (c) 2014年 MyCompany. All rights reserved.
//

#import "PhotoTableViewCell.h"

#define PHOTO_ITEM_VIEW_WIDTH 67

@implementation PhotoTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        
        _photoView = [[PhotoItemView alloc] initWithFrame:CGRectMake(0, 0, PHOTO_ITEM_VIEW_WIDTH, PHOTO_ITEM_VIEW_WIDTH)];
        _photoView.tag = 100;
        _photoView.delegate = self;
        [self addSubview:_photoView];
        
        self.backgroundColor = [UIColor clearColor];
        UIView *selectedView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
        selectedView.backgroundColor = [UIColor clearColor];
        self.selectedBackgroundView = selectedView;
        
        self.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
        self.clipsToBounds = NO;
    }
    return self;
}

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)updateDatas:(id)rowData atIndex:(NSIndexPath *)indexPath {
    _rowData = (UIImage *)rowData;
    
    _indexPath = indexPath;
    
    _photoView.photo = rowData;
}

#pragma makr - PhotoItemViewDelegate
- (void)willDeletePhoto:(PhotoItemView *)photoView {
    if (_delegate && [_delegate respondsToSelector:@selector(willDeleteItem:inCell:)]) {
        [_delegate willDeleteItem:photoView inCell:self];
    }
}

@end
